# This is a Python3 Script used to generate language files for this mod
import json, random, copy, hashlib

colors = ["black","blue","brown","cyan","gray","green","light_blue","light_gray","lime","magenta","orange","pink","purple","red","white","yellow"]
colors_us  = ["Black","Blue","Brown","Cyan","Gray","Green","Light Blue","Light Gray","Lime","Magenta","Orange","Pink","Purple","Red","White","Yellow"]
colors_cn = ["黑色","蓝色","棕色","青色","灰色","绿色","淡蓝色","淡灰色","黄绿色","品红色","橙色","粉色","紫色","红色","白色","黄色"]
colors_jp  = ["黒色","青色","茶色","青緑色","灰色","緑色","空色","薄灰色","黄緑色","赤紫色","橙色","桃色","紫色","赤色","白色","黄色"]

colors_lol  = ["Blak","Bloo","Brownish","Syan","Gray","Greenish","Lite Bloo","Lite Gray","Limd","Majenta","Ornge","Pinky","Parple","Redish","Waite","Yello"]


def getEnNameMine(instr):
    strlst = list(instr)
    toUpper = True
    for char in range(0, len(strlst)):
        if (toUpper and strlst[char] >= 'a' and strlst[char] <= 'z'): # Then to Uppercase
            strlst[char] = chr(ord(strlst[char]) - 32)
        # Reset
        toUpper = False
        if (strlst[char] == '_'):
            toUpper = True
    return "".join(strlst).replace('_', ' ')

def getEnName(instr):
    return instr.replace('_', ' ').title()

def getUpperCap(instr):
    strlst = list(instr)
    toUpper = True
    for char in range(0, len(strlst)):
        if (toUpper and strlst[char] >= 'a' and strlst[char] <= 'z'): # Then to Uppercase
            strlst[char] = chr(ord(strlst[char]) - 32)
        # Reset
        toUpper = False
        if (strlst[char] == ' '):
            toUpper = True
    return "".join(strlst)

def getUpper1st(instr):
    strlst = list(instr)
    if (strlst[0] >= 'a' and strlst[0] <= 'z'): # Then to Uppercase
        strlst[0] = chr(ord(strlst[0]) - 32)
    return "".join(strlst)


# English(United States)  |  en_us.json
obj_us  = {}
# 简体中文(中国)          |  zh_cn.json
obj_cn  = {}
# 日本語　(日本)          |  ja_jp.json
obj_jp  = {}
# LOLCAT(Kingdom of Catz) |  lol_us.json
obj_lol = {}

obj_us['itemGroup.misaka'] = 'Misaka | ミサカ'
obj_cn['itemGroup.misaka'] = '御坂 | ミサカ'
obj_jp['itemGroup.misaka'] = '御坂 | ミサカ'
obj_lol['itemGroup.misaka'] = 'Nyansaka | Meow~'

bloc_id = ['misaka_cake']
bloc_cn = ['御坂蛋糕']
bloc_jp = ['ミサカケーキ']
bloc_lol = ['MISAKA LIEZ']

for i in range(0, len(bloc_id)):
    obj_us['block.misaka.' + bloc_id[i]] = getEnName(bloc_id[i])
    obj_cn['block.misaka.' + bloc_id[i]] = bloc_cn[i]
    obj_jp['block.misaka.' + bloc_id[i]] = bloc_jp[i]
    obj_lol['block.misaka.' + bloc_id[i]] = bloc_lol[i]

item_id = ['coin','canned_cake','canned_misaka_cake','gekota_mask','goggles',
           'music_disc_only_my_railgun','music_disc_only_my_railgun.desc']
item_cn = ['硬币','罐装蛋糕','罐装御坂蛋糕','呱太面具','护目镜',
           '音乐唱片','fripSide - only my railgun']
item_jp = ['コイン','ジャーケーキ','ミサカジャーケーキ','ゲコタの仮面','ゴーグル',
           'レコード','fripSide - only my railgun']
item_lol = ['Shinee Thign!!!','LIEZ IN A JAR','chocolateee liez jar','Frogg Masc','GLASEES',
            'Round loud thing','fripSide - only my railgun']

for i in range(0, len(item_id)):
    obj_us['item.misaka.' + item_id[i]] = getEnName(item_id[i])
    obj_cn['item.misaka.' + item_id[i]] = item_cn[i]
    obj_jp['item.misaka.' + item_id[i]] = item_jp[i]
    obj_lol['item.misaka.' + item_id[i]] = item_lol[i]

# [Gekotas]
for col in range(0, len(colors)):
    obj_us['block.misaka.gekota_' + colors[col]] = colors_us[col] + ' Gekota'
    obj_cn['block.misaka.gekota_' + colors[col]] = colors_cn[col] + '呱太'
    obj_jp['block.misaka.gekota_' + colors[col]] = colors_jp[col] + 'のゲコタ'
    obj_lol['block.misaka.gekota_' + colors[col]] = colors_lol[col] + ' Frogg'


# Write these objects into files in JSON format
with open("en_us.json", "w+") as f:
    data = json.dumps(obj_us, sort_keys=True, indent=4, separators=(',', ': '))
    f.write(data)

with open("zh_cn.json", "w+", encoding='utf-8') as f:
    data = json.dumps(obj_cn, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ': '))
    f.write(data)

with open("ja_jp.json", "w+", encoding='utf-8') as f:
    data = json.dumps(obj_jp, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ': '))
    f.write(data)

with open("lol_us.json", "w+") as f:
    data = json.dumps(obj_lol, sort_keys=True, indent=4, separators=(',', ': '))
    f.write(data)

